﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ReportLogImportExport.ascx.cs" Inherits="ERP.Modules.Report.ReportLogImportExport" %>
<script type="text/javascript">
    var indMoney = function (v) {
        v = (Math.round((v - 0) * 100)) / 100;
        v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
        v = String(v);
        var ps = v.split('.'),
            whole = ps[0],
            sub = ps[1] ? '.' + ps[1] : '.00',
            r = /(\d+)(\d{3})/;
        while (r.test(whole)) {
            whole = whole.replace(r, '$1' + ',' + '$2');
        }
        v = whole;

        return v;
    };
    var NumCheck = function () {
        var x = window.App.txtSumPrice.getValue();
        var y = window.App.txtSumVAT.getValue();
        var k = window.App.txtShippingFee.getValue();
        var z = parseFloat(x.replace(/[,]/g, "")) + parseFloat(y.replace(/[,]/g, "")) + parseFloat(k.replace(/[,]/g, ""));
        window.App.txtSumTotalCash.setValue(z);
        window.App.txtShippingFee.setValue(FormatNumber(k));
    };
</script>
<%-------------------------------%>
<ext:Hidden ID="FormatTypeReportLogImportExport" runat="server" />
<ext:Panel runat="server" Layout="Fit" Border="False" ID="PanelReportLogImportExport">
    <Content>
        <%--------------GridReportLogImportExport-----------------%>
        <ext:GridPanel
            ID="grReportLogImportExport"
            Cls="grid-double"
            runat="server"
            EnableColumnMove="true"
            Border="False">
            <Store>
                <%-------------StoreReportLogImportExport-----------------%>
                <ext:Store
                    ID="StoreReportLogImportExport"
                    runat="server"
                    OnReadData="StoreReportLogImportExport_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model ID="ModelReportLogImportExport" runat="server">
                            <Fields>
                                <ext:ModelField Name="No" Type="String" />
                                <ext:ModelField Name="Date" Type="Date" />
                                <ext:ModelField Name="Materials_Name" Type="String" />
                                <ext:ModelField Name="Unit_Name" Type="String" />
                                <ext:ModelField Name="Materials_Type_Name" Type="String" />
                                <ext:ModelField Name="Quantity_Import" Type="Int" />
                                <ext:ModelField Name="PriceImport" Type="Float" />
                                <ext:ModelField Name="TotalPriceImport" Type="Float" />
                                <ext:ModelField Name="Quantity_Export" Type="Int" />
                                <ext:ModelField Name="PriceExport" Type="Float" />
                                <ext:ModelField Name="TotalPriceExport" Type="Float" />
                                <ext:ModelField Name="Room_Name" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:RowNumbererColumn ID="RowNumbererColumn1" Text="STT" runat="server" Width="30" Align="Center" />
                    <ext:Column ID="Column2" runat="server" Text="Mã chứng từ" Width="100" DataIndex="No"></ext:Column>
                    <ext:DateColumn ID="Column3" runat="server" Text="Ngày" DataIndex="Date" Format="dd-MM-yyyy" Width="100"></ext:DateColumn>
                    <ext:Column ID="Column1" runat="server" Text="Tên vật tư" DataIndex="Materials_Name"></ext:Column>
                    <ext:Column ID="Column5" runat="server" Text="Đơn vị tính" DataIndex="Unit_Name"></ext:Column>
                    <ext:Column ID="Column6" runat="server" Text="Loại vật tư" DataIndex="Materials_Type_Name" Width="120"></ext:Column>
                    <ext:Column ID="Column7" runat="server" Text="SL Nhập" DataIndex="Quantity_Import"></ext:Column>
                    <ext:Column ID="Column9" runat="server" Text="ĐG Nhập" DataIndex="PriceImport">
                        <Renderer Handler="return indMoney(value);" />
                    </ext:Column>
                    <ext:Column ID="Column10" runat="server" Text="TG Nhập" DataIndex="TotalPriceImport">
                        <Renderer Handler="return indMoney(value);" />
                    </ext:Column>
                    <ext:Column ID="Column8" runat="server" Text="SL Xuất" DataIndex="Quantity_Export"></ext:Column>
                    <ext:Column ID="Column11" runat="server" Text="ĐG Xuất" DataIndex="PriceExport">
                        <Renderer Handler="return indMoney(value);" />
                    </ext:Column>
                    <ext:Column ID="Column12" runat="server" Text="TG Xuất" DataIndex="TotalPriceExport">
                        <Renderer Handler="return indMoney(value);" />
                    </ext:Column>
                    <ext:Column ID="Column4" runat="server" Text="Phòng chứa" Width="100" DataIndex="Room_Name" Flex="1"></ext:Column>
                </Columns>
            </ColumnModel>
            <SelectionModel>
                <ext:CheckboxSelectionModel ID="CheckboxSelectionModelReportLogImportExport" runat="server" Mode="Multi">
                    <Listeners>
                        <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnExport}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnExport}.enable();
                            }" />
                    </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <DockedItems>
                <ext:Toolbar ID="ToolbarTopMain" runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grReportLogImportExport}, #{FormatTypeReportLogImportExport}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>

                    </Items>
                </ext:Toolbar>
                <ext:Toolbar ID="ToolbarPagging" runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:PagingToolbar ID="PagingToolbarReportLogImportExport" runat="server" StoreID="StoreReportLogImportExport" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
